/* eslint-disable prettier/prettier */
import React, { Component } from 'react';
import { Form } from 'antd';
import { SecondHeaderC, PrimaryC, TradingMarketC,AdvancedSearch,DATA_ENTRY } from '@/src/components';

class TradingMarketCTest extends Component {
  constructor(props) {
    super(props);
    this.formRef = React.createRef();
    this.state = {
      loading: true,
      t3: undefined,
    };

    setTimeout(() => {
      this.setState({
        t3: '105',
        loading: false,
      });
    }, 2000);
  }

  handleChangeData = () => {
    this.state.TradingMarketC.setSelect('105');
  };

  render() {
    return (
      <div style={{ width: '800px' }}>
        <Form ref={this.formRef}>
          <div>
            <SecondHeaderC title='无初始化值' />
            <TradingMarketC 
            form={this.formRef.current} 
            dataIndex={'t1'}
            rules={[{required:true,message:"必填"}]}
            helper='lalal'
            onChange={(e) => console.log(e)} />

          </div>
          <div className='sectionItem'>
            <SecondHeaderC title='同步加载初始化值dataType==2' />
            <TradingMarketC form={this.formRef.current}
             dataType={2} 
              dataIndex={'t2'}
              initialValue={'1'} 
              marketType={['jys', 'yhj']}
              onChange={(e) => console.log(e)} />
          </div>
          <div className='sectionItem'>
            <SecondHeaderC title='异步加载初始化值' />
            <TradingMarketC
              form={this.formRef.current}
              dataIndex={'t3'}
              disabled={true}
              initialValue={this.state.t3}
              onChange={(e) => console.log(e)}
              loading={this.state.loading}
            />
          </div>
          <div className='sectionItem'>
            <SecondHeaderC title='更改数据' />
            <TradingMarketC
              form={this.formRef.current}
              dataIndex={'t4'}
              onChange={(e) => console.log(e)}
              onRef={(ref) => {
                this.setState({ TradingMarketC: ref });
              }}
            />
            <PrimaryC title='更改选项' style={{marginLeft:'20px'}} onClick={this.handleChangeData} />
          </div>
        </Form>
        <div  style={{marginLeft:'20px',marginTop:'15px'}}>
          <AdvancedSearch
          dataSource={[
            {
              dataIndex: 't5',
              type: DATA_ENTRY.TRADINGMARKET,
              initialValue: this.state.t3,
            },
          ]}
          onQuery={(e) => console.log(e)}
        />
        </div>
      </div>
    );
  }
}

export default TradingMarketCTest;
